<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>ProductTask Index</title>
		<link rel="stylesheet" href="${request.contextPath}/static/asset/jquery-ui/1.11.1/jquery-ui.min.css">
		<link rel="stylesheet" href="${request.contextPath}/static/asset/jqGrid/4.6.0/css/ui.jqgrid.css">
		<#include "../../inc/css.ftl">
   
	</head>
	<body class="no-skin">
		<div class="container-fluid">
			<div class="row">
			  <div class="breadcrumbs">
				<ul class="breadcrumb">
					<li><i class="ace-icon fa fa-home home-icon"></i><a href="${request.contextPath}/index.jspx" target="_top">首页</a></li>
					<li><a href="">生产管理</a></li>
					<li><a href="index.jspx">工位操作</a></li>
					<li class="active">工作区</li>
				</ul>
				  <!-- /.breadcrumb -->
			  </div>
			  <!-- /.breadcrumbs -->
			</div>
			<!-- /.row -->
			<div class="row">
				
				<div id="alert-message"></div>
				<script id="alert-template" type="text/html">
					<div class="alert alert-danger alert-dismissible fade in" role="alert">
				      <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				      <h4>获取计划信息出现错误</h4>
				      <div>{{message}}</div>
				    </div>
				  <!-- /.alert -->
				  </script>
			  
				<div class="page-content">
				
				<ul class="nav nav-tabs">
					<li role="presentation"><a href="#card-noconfirm" data-toggle="tab" data-toggle="tab">待确认生产计划 <span class="badge" id="badge-noconfirm"></span></a></li>
					<li role="presentation"><a href="#card-nomaterial" data-toggle="tab">申请原材料 <span class="badge" id="badge-nomaterial"></span></a></li>
					<li role="presentation"><a href="#card-noproduct" data-toggle="tab">待生产计划 <span class="badge" id="badge-noproduct"></span></a></li>
					<li role="presentation" class="active"><a href="#card-producting" data-toggle="tab">生产中计划 <span class="badge" id="badge-producting"></span></a></li>
					
				</ul>
			   <div class="tab-content">
			      <div class="tab-pane card-body" id="card-noconfirm">
			      		<table class="table table-bordered" id="table-noconfirm">
			      		</table>
			      		<script type="text/html" id="template-noconfirm">
			      		      {{if hasContent}}
			      		      <thead>
								<tr>
									<td>序号</td>
									<td>计划编号</td>
									<td>工序</td>
									<td>规格型号</td>
									<td>长度（米）</td>
									<td>开始日期</td>
									<td>完成日期</td>
									<td>备注</td>
									<td>操作</td>
								</tr>
								</thead>
								<tbody>
								{{each planDetails as planDetail index}}
							    <tr>
								    <td style="text-align:center">{{index+1}}</td>
									<td>{{planDetail.planCode}}</td>
									<td>{{planDetail.process}}</td>
									<td>{{planDetail.materialModel}} ({{planDetail.materialDesc}})</td>
									<td>{{planDetail.needTotal}}({{planDetail.unit}})</td>
									<td>{{planDetail.createDate}}</td>
									<td>{{planDetail.finishDate}}</td>
									<td>{{planDetail.memo}}</td>
									<td>
										{{if planDetail.hasPreProcess}}
										      <span style="color:red;font-weight:bold">前工序：</span>{{planDetail.processMessage}}
										{{else}}
										<a class="btn btn-primary" href="javascript:void(0)" onclick="javascript:product.ProductTask.confirm({{planDetail.id}},'${request.contextPath}')">确认</a>
										{{/if}}
									</td>
							    </tr>
								{{/each}}
								</tbody>
								{{/if}}
								{{if noContent}}
								<thead><tr><td>无相关数据</td></tr></thead>	
							    {{/if}}
			      		</script>
			      </div>
			     <!-- /.待确认计划-->
			     <div class="tab-pane card-body" id="card-nomaterial">
			           <table class="table table-bordered" id="table-nomaterial">
			      		</table>
			      		<script type="text/html" id="template-nomaterial">
			      		      {{if hasContent}}
			      		      <thead>
								<tr>
									<td>序号</td>
									<td><input type="checkbox" id="apply_all" value="0"></td>
									<td>计划编号</td>
									<td>任务单号</td>
									<td>规格型号</td>
									<td>长度（米）</td>
									<td>开始日期</td>
									<td>完成日期</td>
									<td>备注</td>
									<td>操作</td>
								</tr>
								</thead>
								<tbody>
								{{each productTasks as productTask index}}
							    <tr>
								    <td>{{index+1}}</td>
								    <td>
								         {{if productTask.status=="NoMaterial"}}
                                         <input type="checkbox" name="apply_taskid" value="{{productTask.id}}">
                                         {{else}}
                                         <input type="checkbox" name="apply_taskid" value="{{productTask.id}}" disabled>
                                         {{/if}}
                                         </td>
									<td>{{productTask.planDetail.planCode}}</td>
									<td>{{productTask.code}}</td>
									<td>{{productTask.planDetail.materialModel}} ({{productTask.planDetail.materialDesc}})</td>
									<td>{{productTask.planDetail.needTotal}}({{productTask.planDetail.unit}})</td>
									<td>{{productTask.planDetail.createDate}}</td>
									<td>{{productTask.planDetail.finishDate}}</td>
									<td>{{productTask.planDetail.memo}}</td>
									<td>
										{{if productTask.status=="NoMaterial"}}
										<a class="btn btn-primary" href="javascript:void(0)" onclick="javascript:product.ProductTask.applyMaterial({{productTask.id}},'${request.contextPath}');">申请原材料</a>
										{{else if productTask.status=="ApplingMaterial"}}
										    <button class="btn btn-default" disabled>等待原材料返回</button>
										{{else}}
										   <a class="btn btn-success" href="javascript:void(0)" onclick="javascript:product.ProductTask.showApply({{productTask.id}},'${request.contextPath}');">查看原材料</a>
										{{/if}}
									</td>
							    </tr>
								{{/each}}
								</tbody>
								{{/if}}
								{{if noContent}}
								<thead><tr><td>无相关数据</td></tr></thead>
							    {{/if}}
			      		</script>
			      </div>
			   <!-- /.申请原材料-->
			      <div class="tab-pane card-body" id="card-noproduct">
			           <table class="table table-bordered" id="table-noproduct">
			      		</table>
			      		<script type="text/html" id="template-noproduct">
			      		      {{if hasContent}}
			      		      <thead>
								<tr>
									<td>序号</td>
									<td>计划编号</td>
									<td>任务单号</td>
									<td>工序</td>
									<td>规格型号</td>
									<td>数量</td>
									<td>开始日期</td>
									<td>完成日期</td>
									<td>备注</td>
									<td>操作</td>
								</tr>
								</thead>
								<tbody>
								{{each productTasks as productTask index}}
							    <tr>
								    <td>{{index+1}}</td>
									<td>{{productTask.planDetail.planCode}}</td>
									<td>{{productTask.code}}</td>
									<td>{{productTask.planDetail.process}}</td>
									<td>{{productTask.planDetail.materialModel}} ({{productTask.planDetail.materialDesc}})
									    <br/>
									    <a class="btn btn-primary btn-sm" style="margin:1px" href="../card/view.jspx?f={{productTask.cardname}}" target="_blank">工艺卡</a>
										<a class="btn btn-primary btn-sm" style="margin:1px" href="javascript:void(0)" onclick="javascript:product.ProductTask.showProperties('${request.contextPath}','{{productTask.planDetail.process}}','{{productTask.planDetail.materialCode}}','{{productTask.planDetail.destCode}}')">工艺参数</a>
									</td>
									<td>{{productTask.planDetail.needTotal}}({{productTask.planDetail.unit}})</td>
									<td>{{productTask.planDetail.createDate}}</td>
									<td>{{productTask.planDetail.finishDate}}</td>
									<td>{{productTask.planDetail.memo}}</td>
									<td>
										<a class="btn btn-primary" style="margin:3px" href="javascript:void(0)" onclick="javascript:product.ProductTask.start({{productTask.id}},'${request.contextPath}')">开始生产</a>&nbsp;&nbsp;
										
									</td>
							    </tr>
								{{/each}}
								</tbody>
								{{/if}}
								{{if noContent}}
								<thead><tr><td>无相关数据</td></tr></thead>
							    {{/if}}
			      		</script>
			      </div>
			   <!-- /.待生产计划-->
			      <div class="tab-pane active card-body" id="card-producting">
			      		<table class="table table-bordered" id="table-producting">
			      		</table>
			      		<script type="text/html" id="template-producting">
			      		      {{if hasContent}}
			      		      <thead>
								<tr>
									<td>序号</td>
									<td>计划编号</td>
                                    <td>任务单号</td>
									<td>工序</td>
									<td>规格型号</td>
									<td>数量</td>
									<td>开始日期</td>
									<td>完成日期</td>
									<td>备注</td>
									<td>操作</td>
								</tr>
								</thead>
								<tbody>
								{{each productTasks as productTask index}}
							    <tr>
								    <td>{{index+1}}</td>
									<td>{{productTask.planDetail.planCode}}</td>
									<td>{{productTask.code}}</td>
									<td>{{productTask.planDetail.process}}</td>
									<td>{{productTask.planDetail.materialModel}} ({{productTask.planDetail.materialDesc}})
										<br/>
										<a class="btn btn-primary btn-sm" href="../card/view.jspx?f={{productTask.cardname}}" target="_blank">工艺卡</a>&nbsp;
										
										<a class="btn btn-primary btn-sm" href="javascript:void(0)" onclick="javascript:product.ProductTask.showProperties('${request.contextPath}','{{productTask.planDetail.process}}','{{productTask.planDetail.materialCode}}','{{productTask.planDetail.destCode}}')">工艺参数</a>
										
									</td>
									<td>{{productTask.planDetail.needTotal}} {{productTask.planDetail.unit}}</td>
									<td>{{productTask.planDetail.createDate}}</td>
									<td>{{productTask.planDetail.finishDate}}</td>
									<td>{{productTask.planDetail.memo}}</td>
									<td>
										{{if productTask.status=="ShortError"}}
										<a class="btn btn-info btn-sm" href="javascript:void(0)" style="margin:1px" onclick="javascript:product.ProductTask.continueProducting({{productTask.id}})">恢复生产</a>
										{{else}}
										<a class="btn btn-warning" href="javascript:void(0)" style="margin:1px" onclick="javascript:product.ProductTask.showProblem({{productTask.id}})">发生故障</a>&nbsp;&nbsp;
										<a class="btn btn-primary" href="javascript:void(0)" style="margin:2px" onclick="javascript:product.ProductTask.finish({{productTask.id}})">完成生产</a>
										{{/if}}
									</td>
							    </tr>
								{{/each}}
								</tbody>
								{{/if}}
								{{if noContent}}
								<thead>
								<tr><td>无相关数据</td></tr>	
								</thead>	
							    {{/if}}
			      		</script>
			      </div>
			   <!-- /.生产中计划-->

			</div>
			<!-- /.tab-content -->
			</div>
			<!-- /.page-content -->
		</div>
		
		<!-- .modal -->
<div class="modal fade" id="stack-out-modal" tabindex="-1" role="dialog" aria-labelledby="stackModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <form method="post" id="material_stock_out_form" action="submitApply.jspx?format=json" onsubmit="return false;">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="stackModalLabel">申请原材料</h4>
      </div>
      <div class="modal-body">        
          <input type="hidden" id="apply_count" name="apply_count" value="0">
          <input type="hidden" id="taskIds" name="taskIds">
          <table class="table table-bordered">
              <thead>
                  <tr>
                      <td>序号</td>
                      <td>任务单</td>
                      <td>物料代号</td>
                      <td>名称</td>
                      <td>数量</td>
                      <td>备注</td>
                  </tr>
                  <tbody id="materials-body"></tbody>
                  <script id="template-materials-body" type="text/html">
                  {{each materialStockOuts as materialStockOut index}}
                  <tr>
                      <td>{{index+1}}</td>
                      <td><input type="hidden" name="taskId_{{index}}" value="{{materialStockOut.productTask.id}}">{{materialStockOut.productTask.code}}</td>
                      <td><input type="hidden" name="material_code_{{index}}" value="{{materialStockOut.material.code}}">{{materialStockOut.material.code}}</td>
                      <td>{{materialStockOut.material.name}} {{materialStockOut.material.fullname}} {{materialStockOut.material.color}}</td>
                      <td><input type="hidden" name="finalUnit_{{index}}" value="{{materialStockOut.finalUnit}}"><input name="needNum_{{index}}" size="8" value="{{materialStockOut.needNum}}">({{materialStockOut.finalUnit}})</td>
                      <td><input name="memo_{{index}}" placeholder="备注"></td>
                  </tr>
                  {{/each}}
                  </script>
              </thead>
          </table>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="submit" class="btn btn-primary" onclick="javascript:product.ProductTask.submitApply('${request.contextPath}');">提交申请</button>
      </div>
      </form>
    </div>
  </div>
</div>
		<!-- /.modal -->
		
		<div class="modal fade" id="return-stack-out-modal" tabindex="-1" role="dialog" aria-labelledby="stackModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
    <form method="post" id="show_material_stock_out_form" action="confirmApply.jspx?format=json">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="return-stackModalLabel">原材料申请信息</h4>
      </div>
      <div class="modal-body">
      	  <input type="hidden" id="return_stock_out_card_id" name="cardId" value="0">
      	          
          <table class="table table-bordered">
              <thead>
                  <tr>
                      <td>序号</td>
                      <td>编号</td>
                      <td>名称</td>
                      <td>申请数量</td>
                      <td>实际数量</td>
                      <td>备注</td>
                  </tr>
                  <tbody id="return-materials-body"></tbody>
                  <script id="return-template-materials-body" type="text/html">
                  {{each materialStockOuts as materialStockOut index}}
                  <tr>
                      <td><input type="hidden" name="id" value="{{materialStockOut.id}}">{{index+1}}</td>
                      <td>{{materialStockOut.material.code}}</td>
                      <td>{{materialStockOut.material.name}} {{materialStockOut.material.fullname}} {{materialStockOut.material.color}}</td>
                      <td>{{materialStockOut.needNum}}({{materialStockOut.finalUnit}})</td>
                      <td>{{materialStockOut.finalNum}}({{materialStockOut.finalUnit}})</td>
                      <td><input type="text" size="10" name="memo_{{id}}" value="{{materialStockOut.memo}}"></td>
                  </tr>
                  {{/each}}
                  </script>
              </thead>
          </table>
          
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" style="margin:2px" data-dismiss="modal">关闭</button>&nbsp;&nbsp;
        <button type="submit" class="btn btn-primary" style="margin:2px" onclick="javascript:product.ProductTask.confirmApply('${request.contextPath}');">确认原材料</button>
      </div>
</form>
    </div>
  </div>
</div>
		<!-- /.modal -->
		
<#include "problem_confirm.ftl">
<#include "properties_show.ftl">
		<#include "../../inc/js.ftl">
		<script src="${request.contextPath}/static/asset/jquery/jquery.form.js"></script>
		<script src="${request.contextPath}/static/asset/zTree/3.5.17/js/jquery.ztree.core-3.5.js"></script>
		<script src="${request.contextPath}/static/asset/jquery-ui/1.11.1/jquery-ui.min.js"></script>
		<script src="${request.contextPath}/static/asset/jqGrid/4.6.0/js/i18n/grid.locale-cn.js"></script>
		<script src="${request.contextPath}/static/asset/jqGrid/4.6.0/js/jquery.jqGrid.min.js"></script>
		<script src="${request.contextPath}/static/skin/default/js/custom-jqgrid.js"></script>
		<script src="${request.contextPath}/static/asset/jquery/template.js"></script>
		<script src="${request.contextPath}/static/skin/default/js/product-list.js"></script>
		<script>
			$(document).ready(function(){
				product.ProductTask.init();
			});
		</script>	
	</body>
</html>